#include "amutils.h"
#include <cstdlib>

float AMUtils::revEndian(float f) {
    const int n = sizeof(float);
    union {
        float val;
        unsigned char bytes[n];
    } f1, f2;

    f1.val = f;
    int i = 0;
    int c = n - 1;
    for(; i < n; i++, c--) {
        f2.bytes[i] = f1.bytes[c];
    }

    return f2.val;
};

void AMUtils::freeMeshData(MeshData * m) {
    if(m == 0) return;
    free(m->ninds);
    free(m->vinds);
    free(m->tinds);
    free(m->norms);
    free(m->verts);
    free(m->txcos);
    free(m);
    m = 0;
};
